package com.yylany.controller;

import com.yylany.enums.ResultEnum;
import com.yylany.pojo.TbBrand;
import com.yylany.service.BrandService;
import com.yylany.vo.BrandsResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Description: pinyougou
 *
 * @author <a href="mailto:17777502615@163.com">yaoyonglong</a>
 * @date 2018/12/19
 * @since 1.0.0
 */
@RestController
@RequestMapping
public class BrandsController {

    @Autowired
    private BrandService brandService;

    /**
     * 通过CategoryId 查询所有的品牌
     *
     * @param catid CategoryId
     * @return BrandsResult
     */
    @GetMapping("/brands/{catid}")
    public BrandsResult brands(@PathVariable("catid") int catid) {
        List<TbBrand> brands = brandService.brands(catid);
        BrandsResult brandsResult = new BrandsResult(
                ResultEnum.CATEGORY_SUCCESS.getErrno(),
                ResultEnum.CATEGORY_SUCCESS.getErrmsg(),
                brands);

        return brandsResult;
    }


}
